// pages/mine/manager_list/manager_list.js
var common = require('../../../utils/common.js')
var util = require('../../../utils/util.js')
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    manageList:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (!app.globalData.managerLogin) {
      // 跳转到登录界面
      wx.navigateTo({
        url: '/pages/mine/manager_login/manager_login',
      })
      return
    }
    var that = this
    that.getTokenAndData()
  },
  getTokenAndData: function () {
    var that = this
    wx.showToast({
      title: '加载中',
      icon: 'loading',
      duration: 10000
    })
    if (app.globalData.wangcaiToken) {
      // console.log(app.globalData.wangcaiToken)
      // console.log("直接获取")
      that.getData();
    } else {
      // console.log("间接获取")
      //调用应用实例的方法获取全局数据
      app.getToken(function (wangcaiToken) {
        //更新数据
        that.getData();
      })
    }
  },
  getData: function () {
    var that = this
    that.setData({
      manageList: [{ 'title': '推荐页数据上传', 'page': '/pages/mine/cheap/cheap' }, { 'title': '邮政车险', 'page': '/pages/mine/post_auto_insurance/post_auto_insurance'  }]
    })
    wx.hideToast()
  },
  manageClick: function (e) {
    var that = this
    wx.navigateTo({
      url: that.data.manageList[e.currentTarget.dataset.index].page
    })
  }
})